package org.wxd.sign.utils;

import org.wxd.sign.annotation.SignApi;
import org.wxd.sign.annotation.SignType;

import java.util.Map;
import java.util.Objects;
import java.util.stream.Stream;

public class SignUtils {


    public static boolean isSignInput(SignApi signApi){
        return Objects.nonNull(signApi) && Stream.of(signApi.signType()).anyMatch(type -> Objects.equals(SignType.ALL,type) || Objects.equals(SignType.INPUT,type));
    }

    public static boolean isSignError(Map<String, String> codeSignMap) {
        return Objects.isNull(codeSignMap) ||
                codeSignMap.entrySet().stream().anyMatch(
                        entry -> !Objects.equals(entry.getValue(),Sha1Utils.getSha1(entry.getKey()))
                );
    }


    public static String signSuffix(){
        return "Signature";
    }
}
